package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Customer;
import cn.wolfcode.crm.mapper.CustomerMapper;
import cn.wolfcode.crm.qo.QueryObject;
import cn.wolfcode.crm.service.CustomerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService {
    @Autowired
    private CustomerMapper customerMapper;

    @Override
    public void insert(Customer customer) {
        customerMapper.insert(customer);
    }


    @Override
    public Customer selectByPrimaryKey(Long id) {

        return customerMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Customer> selectAll() {
        return customerMapper.selectAll();
    }


    @Override
    public void updateByPrimaryKey(Customer customer) {
        customerMapper.updateByPrimaryKey(customer);
    }

    @Override
    public PageInfo<Customer> query(QueryObject qo) {
       //查询部门数据
        PageHelper.startPage(qo.getCurrentPage(),qo.getPagSize());

        return new PageInfo<>(customerMapper.queryForList(qo));
    }

}
